package com.wfm.eduservice.controller;


import com.wfm.commonutils.R;
import com.wfm.eduservice.entity.EduChapter;
import com.wfm.eduservice.entity.EduVideo;
import com.wfm.eduservice.service.EduVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author wfm
 * @since 2021-03-10
 */
@RestController
@RequestMapping("/eduservice/video")
@CrossOrigin
public class EduVideoController {

    @Autowired
    EduVideoService videoService;

    //添加video
    @PostMapping("addVideo")
    public R addVideo(@RequestBody  EduVideo eduVideo){
        videoService.save(eduVideo);
        return R.ok();
    }
    //删除video
    @DeleteMapping("deleteVideo/{videoId}")
    public R deleteVideo(@PathVariable String videoId){
        videoService.removeById(videoId);
        return R.ok();

    }
    //根据id修改video
    @PostMapping("updateVideo")
    public R updateVideo(@RequestBody EduVideo video){
        videoService.updateById(video);
        return R.ok();

    }
    //根据id查video
    @GetMapping("getVideoInfo/{videoId}")
    public R getVideoInfo(@PathVariable String videoId){
        EduVideo video = videoService.getById(videoId);
        return R.ok().data("video",video);
    }

}

